package com.zzy.mccjt.config;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

/**
 * @program: mccjt-cloud
 * @description: RestTemplate
 * @author: zhouyang.zheng
 * @create: 2022-08-01 15:18
 **/
@Configuration
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RestTemplateConfig {

    private final RestTemplateBuilder builder;

    @Bean
    public RestTemplate restTemplate(){
        return builder
                .setConnectTimeout(Duration.ofSeconds(60))
                .setReadTimeout(Duration.ofSeconds(60))
                .build();
    }

}
